import { get, post } from '@/utils/request'

export const listAllCity = async () => {
    try {
        const response = await get<any>('/user/listAllCity');
        return response;
    } catch (error) {
    }
};

export const getCitySetting = async () => {
    try {
        const response = await get<any>('/user/getCitySetting');
        return response;
    } catch (error) {
    }
};

export const citySetting = async (data: any) => {
    try {
        const response = await post<any>('/user/citySetting', data);
        return response;
    } catch (error) {
    }
};

export const getWeatherByCity = async (data: any) => {
    try {
        const response = await get<any>('/user/getWeatherByCity', data);
        return response;
    } catch (error) {
    }
};

export interface CitySettingRequest {
    city: string,
}

export interface WeatherInfo {
    // 数据更新时间（该城市的本地时间）
    lastUpdate: string,
    daily: WeatherAPIDaily[],
}

export const getWeatherIcon =(code: string)=>{
    const baseUri = '/wheather/';
    return baseUri + code +'@1x.png';
}

interface WeatherAPIDaily {
    date: string,
    textDay: string,
    codeDay: string,
    textNight: string,
    codeNight: string,
    high: string,
    low: string,
    rainfall: string,
    precip: string,
    windDirection: string,
    windSpeed: string,
    windScale: string,
    humidity: string,
}
